<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<link type="text/css" rel="stylesheet" href="${ctx }/resources/js/jstree/themes/default/style.css"/>
<script type="text/javascript" src="${ctx }/resources/js/jstree/jstree.min.js"></script>   
<script type="text/javascript" src="${ctx }/resources/js/jstree/jstree.checkbox.js"></script> 
<script type="text/javascript" src="${ctx }/resources/js/underscore/underscore-min.js"></script> 
  <script type="text/javascript">
$(function() {
	webside.form.bvideo.initResource();
	webside.form.bvideo.BvideoForm();
	
});
</script>  


<script src="${ctx }/resources/js/upload/ajaxfileupload.js"
	type="text/javascript">
</script>
<script type="text/javascript">
function s(e,a)
{
	 if ( e && e.preventDefault )
            e.preventDefault();
	else 
	window.event.returnValue=false;
		a.focus();
		
}
	function doSaveCover() {
		var fileName = $("#cover").val();
		var type = fileName.split(".");
		var ftype = type[type.length - 1]; //获取文件后缀
		$.ajaxFileUpload({
			url :'${ctx }/files/upload/' + ftype,
			secureuri : false, //是否需要安全协议，一般设置为false
			fileElementId : [ 'cover' ], //文件上传域的ID
			dataType : 'json', //返回值类型 一般设置为json
			success : function(data, status) //服务器成功响应处理函数
			{ 
				if (data.result == 0) {
					var fileId = data.data[0].id;
					var filePath = '/files/view/jpg/' + fileId;
					$("#hiddenCover").val(filePath);
					//显示图片
					$("#imgCover").attr("src",'${ctx }/files/view/jpg/' + fileId);
					//显示名字
					$("#labcover").html(data.data[0].name);
				}
			},
			error : function(data, status, e) //服务器响应失败处理函数
			{
				alert(e);
			}
		});
		
	}

	
	function doSavePoster() {
		var fileName = $("#poster").val();
		var type = fileName.split(".");
		var ftype = type[type.length - 1]; //获取文件后缀
		 
		$.ajaxFileUpload({
			url :'${ctx }/files/upload/' + ftype,
			secureuri : false, //是否需要安全协议，一般设置为false
			fileElementId : [ 'poster' ], //文件上传域的ID
			dataType : 'json', //返回值类型 一般设置为json
			success : function(data, status) //服务器成功响应处理函数
			{ 
				 
				if (data.result == 0) {
					var fileId = data.data[0].id;
					var filePath = '/files/view/jpg/' + fileId;
				 
					$("#hiddenPoster").val(filePath);
					//显示图片
					$("#imgPoster").attr("src",'${ctx }/files/view/jpg/' + fileId);
					//显示名字
					$("#laPoster").html(data.data[0].name);
				}
			},
			error : function(data, status, e) //服务器响应失败处理函数
			{
				alert(e);
			}
		});
	}	  
</script>

<style>
.resourceShow
{
	padding-left: 10px; 
	padding-top: 3px;
}
.source-resourceId
{
	 width:100%;
	 float:left;
}
@media screen and (max-width: 374px){
	.source-resourceId
	{
		 width:82%;
	}
}
@media screen and (min-width: 375px) and (max-width: 449px){
.source-resourceId
	{
		 width:85%;
	}
}
@media screen and (min-width: 450px) and (max-width: 1279px) {
	.source-resourceId
	{
		 width:90%;
	}
}
@media screen and (min_width: 1280px) {
	.source-resourceId
	{
		 width:90%;
	}
}
</style>

<div class="page-header">
    <h1>
		<c:if test="${empty bvideoentity}">
		添加视频资源
		</c:if>
		<c:if test="${!empty bvideoentity}">
		修改视频资源
		</c:if>
	 </h1>
</div>
<div class="row" style="margin-top:5px;">
	<div class="col-xs-12">
		<form id="bvideoForm" name="bvideoForm" class="form-horizontal" role="form" method="post">
		<c:if test="${!empty bvideoentity}">
		<input type="hidden" id="pageNum" name="pageNum" value="${page.pageNum }">
		<input type="hidden" id="pageSize" name="pageSize" value="${page.pageSize }">
		<input type="hidden" id="orderByColumn" name="orderByColumn" value="${page.orderByColumn }">
		<input type="hidden" id="orderByType" name="orderByType" value="${page.orderByType }">
		<input type="hidden" id="bVideoId" name="id" value="${bvideoentity.id }">
		</c:if>
		  <!-- 剧集id的隐藏域-->
		  <input type="hidden" id="seriesId" name="seriesId" value="${seriesId}" />
		  
			<div class="form-group">
				<label class="control-label col-sm-1 no-padding-right"
					for="description">视频标题</label>
				<div class="col-sm-10">
					<div class="clearfix">
						<input class="form-control" name="title" id="title"
							type="text" value="${bvideoentity.title}" placeholder="视频标题" />
					</div>
				</div>
			</div>
			  <div class="form-group">
				<label class="control-label col-sm-1 no-padding-right" for="description">视频描述</label>
				<div class="col-sm-10">
					<div class="clearfix">
						<input class="form-control" name="description" id="description" type="text"
							value="${bvideoentity.description }" placeholder="视频描述"  maxlength='10' />
							<label>最多输入10个字符</label>
					</div>
				</div>
			</div>
			 
			  <div class="form-group">
				<label class="control-label col-sm-1 no-padding-right" for="setNum">第几集</label>
				<div class="col-sm-10">
					<div class="clearfix">
						<input class="form-control" name="setNum" id="setNum" type="text"
							value="${bvideoentity.setNum }" placeholder="第几集"  onkeyup="value=value.replace(/[^(\d)]/g,'')"/>
							<label>只能输入数字</label>
					</div>
				</div>
			</div>
		 
			 <div  id="resourceDiv" class="form-group">
				<label class="control-label col-sm-1 no-padding-right" for="resourceId">视频资源</label>
				<div class="col-sm-10">
					<div class="clearfix">
					<input type="hidden" id="resourceId" name="resourceId" value="${bvideoentity.resourceId}" />
					
						<input class="form-control source-resourceId" name="resourceName" id="resourceName" type="text"
							  placeholder="视频资源" value="${bvideoentity.resourceName}" />
							  
						<i id="resourceShow" data-rel="tooltip" data-placement="left"  data-original-title="点击清除" ></i>
					</div>
				</div>
			</div>  
		</form>
		<div class="hr hr-dotted"></div>
	</div>
</div>
<div class="center">
	<button id="btnAdd" type="button"
		onclick="javascript:$('#bvideoForm').submit();"
		class="btn btn-success btn-sm">
		<i class="fa fa-user-plus"></i>&nbsp; 
		<c:if test="${empty bvideoentity}">
		添加
		</c:if>
		<c:if test="${!empty bvideoentity}">
		保存
		</c:if>   
	</button>
	<button id="btn" type="button"
		onclick="webside.common.loadPage('/bvideo/listUI.html<c:if test="${!empty bvideoentity}">?id=${bvideoentity.seriesId}&page=${page.pageNum}&rows=${page.pageSize }&sidx=${page.orderByColumn }&sord=${page.orderByType }</c:if>')"
		class="btn btn-info btn-sm">
		<i class="fa fa-undo"></i>&nbsp;返回
	</button>
</div>
 
 
 
 